package com.colin.distributelock.service;

import com.colin.distributelock.lock.RedisLock;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * Created by Colin on 2020/8/31 21:24
 * email: colinzhaodong@gmail.com
 * desc:
 *
 * @author zhaod
 */
@Service
@Slf4j
public class SchedulerService {
	@Autowired
	private RedisTemplate redisTemplate;

	//@Scheduled(cron= "0/5 * * * * ?")
	public void sendSms() {
		try (RedisLock redisLock = new RedisLock(redisTemplate, "message-schedular", 30)) {
			if (redisLock.getLock()) {
				log.info("向13815253473发送短信");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
